# Maintainer: Chih-Hsuan Yen <yan121215@archlinux.org>
# Contributor: Ye Jingchen <ye.jingchen@gmail.com>

pkgname=capitaine-cursors
pkgver=4
pkgrel=2
pkgdesc="An x-cursor theme inspired by macOS and based on KDE Breeze"
arch=(any)
url="https://github.com/keeferrourke/capitaine-cursors"
license=(LGPL3)
source=("https://github.com/keeferrourke/$pkgname/archive/r$pkgver/$pkgname-$pkgver.tar.gz"
        "inkscape-needs-integers.diff")
makedepends=(inkscape xorg-xcursorgen bc xorg-server-xvfb)
sha256sums=('41f66e9f4d41729dc5e9185aab3bc4a719fdcca939e6f3f590b6b811b28dedd2'
            '0d83edb268c84a1889cf921c8e1789c609fa191e3bc7fa2ddb70702033713179')

prepare() {
  cd $pkgname-r$pkgver
  # From https://github.com/keeferrourke/capitaine-cursors/pull/44
  sed -i 's#-z -e#-o#' build.sh
  # Fixes "Cannot parse integer value" warnings from inkscape
  # Inspired by https://unix.stackexchange.com/a/320703
  # See also https://github.com/keeferrourke/capitaine-cursors/issues/43#issuecomment-590098233
  patch -Np1 -i ../inkscape-needs-integers.diff
}

build() {
  cd $pkgname-r$pkgver
  for variant in dark light ; do
    # Run in a virtual Xorg server to avoid warnings from Inkscape `Failed to wrap object of type 'GtkRecentManager'`
    xvfb-run --auto-display ./build.sh --max-dpi xxxhd --type $variant
  done
}

package() {
  cd $pkgname-r$pkgver
  install -Ddm755 "$pkgdir/usr/share/icons"
  cp -dr --no-preserve=ownership dist/dark/ "$pkgdir/usr/share/icons/capitaine-cursors"
  cp -dr --no-preserve=ownership dist/light/ "$pkgdir/usr/share/icons/capitaine-cursors-light"
}
